"""
检查生成的csv文件，看它所有的标注是否符合规范
"""
import pandas as pd
from collections import Counter

# 读取 CSV 文件
df = pd.read_csv(r'D:\file\postgrad\experiment\bird_ava_dataset\train_without_personID.csv', header=None)

# 定义范围规则
rules = [
  (1, 698, 1, 6)
]

# 初始化统计变量
invalid_rows = []
count_seventh_column = Counter(df[6])

# 遍历每行，检查是否符合规则
for idx, row in df.iterrows():
  first_col = row[0]
  seventh_col = row[6]

  valid = False
  for (start, end, valid_start, valid_end) in rules:
    if start <= first_col <= end:
      if valid_start <= seventh_col <= valid_end:
        valid = True
      break

  if not valid:
    invalid_rows.append(row)

# 输出不符合规则的行
if invalid_rows:
  print("不符合规则的行:")
  for row in invalid_rows:
    print(row.tolist())

# 输出第七列中每个数字的出现次数
print("\n第七列中每个数字的统计：")
for num, count in count_seventh_column.items():
  print(f"数字 {num}: {count} 次")
